<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>登录</title>

    <link rel="stylesheet" href="/layui/css/layui.css">

    <style type="text/css">
        .login {
            height: 190px;
            width: 340px;
            padding: 20px;
            background-color: rgba(0, 0, 0, 0.5);
            border-radius: 4px;
            position: absolute;
            left: 50%;
            top: 50%;
            margin: -150px 0 0 -150px;
            z-index: 99;
        }
        a{
            width:300px;
        }
        .carousel {
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            z-index: 90;
            background-color: rgba(0, 0, 0, 0.3);
        }
    </style>
</head>
<body>
    <div class="layui-carousel carousel" lay-filter="carousel" id="carousel">
        <div carousel-item="">
<!--            <div><img src="/images/background1.png"></div>-->
<!--            <div><img src="/images/background2.png"></div>-->
        </div>

        <div class="layui-container login">
            <form id="loginForm" action="/user/login"  method="post" class="layui-form">
                <input name="type" type="hidden" value="1">
                <input type="text" name="username" lay-verify="required" placeholder="请输入账号"
                       autocomplete="off" class="layui-input">
                <br>
                <input type="password" name="password" lay-verify="required" placeholder="请输入密码"
                       autocomplete="off" class="layui-input">
                <br>
                <a class="layui-btn layui-btn-normal " lay-filter="submit" lay-submit="" id="submit">登陆
                </a>
            </form>
        </div>
    </div>

    <script src="/layui/layui.js"></script>
    <script src="/js/core.util.js"></script>
    <script>
        layui.use(['form','carousel'],function() {
            var layer = layui.layer;
            var form = layui.form;
            var carousel = layui.carousel;
            form.on('submit(submit)',function (data) {
                CoreUtil.sendAjax("/api/user/login",JSON.stringify(data.field),function (res) {
                    layer.msg(res.msg);
                    console.log(res.data.accessToken)
                    CoreUtil.setData("access_token",res.data.accessToken);
                    CoreUtil.setData("refresh_token",res.data.refreshToken);
                    console.log(CoreUtil.getData("access_token"))
                    window.location.href="/index/excels";
                },'POST',false);
                return false;
            });
            //改变下时间间隔、动画类型、高度
            carousel.render({
                elem: '#carousel'
                ,interval: 2000
                ,anim: 'fade'
                , full: true //全屏
                ,width: '100%'
                ,arrow: 'none'
            });
        });
    </script>

</body>
</html>